package br.inf.solutions.apresentacoes.ssp.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import br.com.vexillum.model.CommonEntityActivated;
import br.com.vexillum.model.annotations.SearchField;
import br.com.vexillum.model.annotations.Validate;
import br.com.vexillum.model.annotations.ValidatorClass;

@SuppressWarnings("serial")
@ValidatorClass(validatorClass="br.inf.solutions.apresentacoes.ssp.control.validator.CityValidator")
@Entity
@Table(name="city")
public class City extends CommonEntityActivated {

	
	public City() {
	
	}
	
	public City(String name) {
		this.name = name;
	}
	
	@SearchField(introspect=true)
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="id_state", nullable=false, updatable=true)
	@Validate(notNull=true)
	private State state;

	@SearchField
	@Column(name="name", nullable=false, unique=false, updatable=true, length=100)
	@Validate(notNull=true, min=3)
	private String name;
	
	@Column(name="cep_general", nullable=false, unique=false, updatable=true, length=20)
	@Validate(notNull=true, min=9)
	private String cepGeneral;

	public State getState() {
		return state;
	}

	public void setState(State state) {
		this.state = state;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCepGeneral() {
		return cepGeneral;
	}

	public void setCepGeneral(String cepGeneral) {
		this.cepGeneral = cepGeneral;
	}

	/*
	 Retorne apenas o nome na lista do combobox que lista as Cidades
	  */
	@Override
	public String toString() {
		return this.name;
	}	
	
}